package com.sky.mapper;

import com.sky.dto.GoodsSalesDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.sql.Timestamp;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface ReportMapper {

//计算指定时间区域的营业额
    @Select("select sum(amount) from orders where status = #{status} and order_time > #{beginTime} and order_time < #{endTime}")
    Double sumTurnover(Integer status, LocalDateTime beginTime, LocalDateTime endTime);
//计算指定时间新用户数量
    @Select("select count(*) from user where create_time > #{beginTime} and create_time < #{endTime}")
    Integer sumNewUser(LocalDateTime beginTime, LocalDateTime endTime);
//计算指定时间所有用户数量
    @Select("select count(*) from user where create_time < #{endTime}")
    Integer sumAllUser(LocalDateTime endTime);
//查询指定时间的所有订单
    @Select("select count(*) from orders where order_time > #{beginTime} and order_time < #{endTime}")
    Integer sumAllOrder(LocalDateTime beginTime, LocalDateTime endTime);
//查询指定时间的所有有效订单
    @Select("select count(*) from orders where order_time > #{beginTime} and order_time < #{endTime} and status = #{completed}")
    Integer sumValidOrder(LocalDateTime beginTime, LocalDateTime endTime, Integer completed);
//整店订单数
    @Select("select count(*) from orders")
    Integer sumOrder();
//整店有效订单数
    @Select("select count(*) from orders where status = #{completed}")
    Integer sumVOrder(Integer completed);
//查询top10商品
    List<GoodsSalesDTO> top10(LocalDateTime begin, LocalDateTime end);
}
